package it.eg.managedcor.impl;

/**
 * Each task execution will return a value of this
 * enum to the task executor.
 * 
 * Based on this result (and eventually on some
 * data present in the session data) the executor 
 * will continue / stop / rollback the execution.
 * 
 * @author Emanuele Gherardini
 *
 */
public enum TaskExecutionResult {

	PERFORMED_CONTINUE_EXECUTION(true,false,false),
	PERFORMED_STOP_EXECUTION(true,true,false),
	PERFORMED_ROLLBACK_EXECUTION(true,true,true),
	
	NOT_PERFORMED_CONTINUE_EXECUTION(false,false,false),
	NOT_PERFORMED_STOP_EXECUTION(false,true,false),
	NOT_PERFORMED_ROLLBACK_EXECUTION(false,true,true);
	
	
	/**
	 * Indicates the task has been successfully performed.
	 */
	private boolean performed;
	
	/**
	 * Indicates the execution of successive tasks should be stopped.
	 */
	private boolean stop;
	
	/**
	 * Indicates the execution of this and previous tasks should be rolled back.
	 */
	private boolean rollback;
	
	
	private TaskExecutionResult(boolean performed, boolean stop, boolean rollback) {
		this.performed = performed;
		this.stop = stop;
		this.rollback = rollback;
	}

	public boolean isPerformed() {
		return performed;
	}

	public boolean isStop() {
		return stop;
	}

	public boolean isRollback() {
		return rollback;
	}
	
	
	@Override
	public String toString() {
		return this.name() + " Performed:" + performed + " Stop:" + stop + " rollback:" + rollback;
	}
	
}
